<?php
header("content-type:text/html;charset=utf-8");

class  student{


	public $name;
	public $school;

	public function say(){

      echo "我是一名学生";
	}
}

class Myclass{


	const CONSTANT="qwerdf";

	function showConstant(){

		echo self::CONSTANT."<br>";
	}
}

echo Myclass::CONSTANT."<br>";
$class=new Myclass;
$class->showConstant();


$wang=new student();
$wang->say();

echo "----------------------------------------------------------------------------------------------------------"."<br>";
$a = "hello";
$b = &$a;
unset($b);

$b = "world";
echo $a;
echo "----------------------------------------------------------------------------------------------------------"."<br>";
echo date("Y年m月d日h:i:s",filectime("./index.php"));
$file=stat("index.php");
print_r(array_slice($file,13));
 print_r(stat("index.php")) ;
echo "----------------------------------------------------------------------------------------------------------"."<br>";

function getFile($filename){



	if(!file_exists($filename)){


		echo "目标文件不存在.<br>";
		return;
	}
	if(file_exists($filename)){

        echo $filename."是一个文件<br>";


	if(is_dir($filename))
		echo $filename."是一个目录文件类型";

}
	}

getFile("C:\Windows");

function Changesiez($size){
   if($size>pow(2,40)){

   	$return=round($size/pow(1024,4),2);
   	$u="TB";
   }
   if($size>pow(2,10)){

   	$return=round($size/pow(1024,1),2);
   	$u="KB";
   }

   return $return.$u;
}


function getFileSize($bytes){

    if($bytes>=pow(2,40)){
    $return=round($bytes/pow(1024,4),2);
    $suffix="TB";
    }elseif($bytes>=pow(2,30)){

       $return=round($bytes/pow(1024,3),2);
       $suffix="GB";
    }
    elseif($bytes>=pow(2,20)){

       $return=round($bytes/pow(1024,2),2);
       $suffix="MB";
    }elseif($bytes>=pow(2,10)){

       $return=round($bytes/pow(1024,1),2);
       $suffix="KB";
    }
    return $return.$suffix;




}
$size=filesize("./index.php");

  echo getFileSize($size);

echo "----------------------------------------------------------------------------------------------------------"."<br>";

$dirname="my";
$dir_handle=opendir($dirname);                //打开指定文件夹
while($file=readdir($dir_handle)){            //读取指定的文件夹,参数为opendir()函数返回的值
$dirfile=$diranme.$file;
echo "$dirfile"."<br>";
}

function dirSize($directory){

$size=0;

if($dir_headle=opendir($directory)){


  while($file=readdir($dir_handle)){


         if($file!="." && $file!=".."){
          $filename=$directory."/".$file;
          if(is_dir($filename)){

              $size+=dirSize($filename);

          }
          if(is_file($filename)){
             $size+=filesize($filename);
          }

        }
   echo "$file";

  } 
 closedir($dir_headle);
 return $size;

}


}

echo dirSize("my");
 $filename="./my/a.txt";
 $handle=fopen($filename,"w");
for($i=0;$i<10;$i++){

	fwrite($handle,$i."www.baidu.com \n");

}
 fclose($handle);

 print_r(file("./my/c.txt"));


?>